1 using UnityEngine;
2 using
System.Collections;
3
4 public
class OnJoinedInstantiate : MonoBehaviour
5 {
6     
public Transform SpawnPosition;
7     
public float PositionOffset = 2.0f;
8     
public GameObject[] PrefabsToInstantiate; // set in inspector
9
10     
public void OnJoinedRoom()
11     {
12         
if (this.PrefabsToInstantiate != null)
13         {
14             
foreach (GameObject o in this.PrefabsToInstantiate)
15             {
16                 Debug.Log(
"Instantiating: " + o.name);
17
18                 Vector3 spawnPos = Vector3.up;
19                 
if (this.SpawnPosition != null)
20                 {
21                     spawnPos =
this.SpawnPosition.position;
22                 }
23
24                 Vector3 random = Random.insideUnitSphere;
25                 random.y =
0;
26                 random = random.normalized;
27                 Vector3 itempos = spawnPos +
this.PositionOffset * random;
28
29                 PhotonNetwork.Instantiate(o.name, itempos, Quaternion.identity,
0);
30             }
31         }
32     }
33 }


public GameObject[] PrefabsToInstantiate; set in inspector




Trò chơi Tic-Tac-Toe, game đánh caro full source code 53.443 lượt xem

Gõ tìm kiếm nhanh...